{% extends "base.html" %}
{% block content %}
<h1>{{ user.username }}'s space</h1>
<p>
  If you see this page, you are connected. Want to try again ?...  <a
  href="/accounts/logout/">logout</a>.</p>
<p>
  It uses the standard decorator
  <code>login_required</code> except you simply declare it when
  defining class.</p>
<div class="highlight"><pre>
<span class="kn">from</span> <span class="nn">obviews.views</span> <span class="kn">import</span> <span class="n">View</span><span class="p">,</span> <span class="n">FormView</span>

<span class="c"># adding authentification</span>
<span class="k">class</span> <span class="nc">PrivateView</span><span class="p">(</span><span class="n">View</span><span class="p">):</span>
    <span class="n">template_name</span> <span class="o">=</span> <span class="s">&quot;private.html&quot;</span>
    <span class="n">login_required</span> <span class="o">=</span> <span class="bp">True</span>
    
<span class="n">urlpatterns</span> <span class="o">=</span> <span class="n">patterns</span><span class="p">(</span><span class="s">&#39;&#39;</span><span class="p">,</span>
    <span class="p">(</span><span class="s">&#39;^private/$&#39;</span><span class="p">,</span> <span class="n">PrivateView</span><span class="p">()),</span>
<span class="p">)</span>

</pre></div>
<p>
  Easy enough! As you can see, not much more code in the view than in
  previous examples... the named vars in URLs are naturally passed
  into context. The <strong>next example</strong> shows how to <a
  href="/now/">change said context</a>, do a bit more of processing...
</p>
{% endblock %}
